INCLUDE_DIRS := -Ilist -Ifile -Ifilter -Itrender -Ifloat -Itime
BUILD_FLAGS := -ansi -O2 -pipe -funsigned-char $(INCLUDE_DIRS)
WARNING_FLAGS := -Wall -Wextra -Wconversion -Werror -pedantic-errors

BUILD_DIR := ../build
OBJECTS := $(patsubst %.c, $(BUILD_DIR)/%.o, $(wildcard *.c))
CXX := gcc -c $(BUILD_FLAGS) $(WARNING_FLAGS) -o $(BUILD_DIR)/

build: $(OBJECTS) | $(BUILD_DIR)
	gcc -o $(BUILD_DIR)/tempfilter $(OBJECTS)

$(BUILD_DIR)/tempfilter.o: tempfilter.c
	$(CXX)tempfilter.o tempfilter.c

$(BUILD_DIR)/d_list.o: d_list.c list/d_list.h
	$(CXX)d_list.o d_list.c

$(BUILD_DIR)/list_data.o: list_data.c list/list_data.h
	$(CXX)list_data.o list_data.c

$(BUILD_DIR)/fcompare.o: fcompare.c float/fcompare.h
	$(CXX)fcompare.o fcompare.c

$(BUILD_DIR)/fread.o: fread.c file/fread.h
	$(CXX)fread.o fread.c

$(BUILD_DIR)/consecutive.o: consecutive.c time/consecutive.h
	$(CXX)consecutive.o consecutive.c

$(BUILD_DIR)/filter.o: filter.c filter/filter.h
	$(CXX)filter.o filter.c

$(BUILD_DIR)/fout.o: fout.c file/fout.h
	$(CXX)fout.o fout.c

$(BUILD_DIR)/trender.o: trender.c trender/trender.h
	$(CXX)trender.o trender.c

$(BUILD_DIR):
	mkdir $(BUILD_DIR)

.PHONY: clean
clean:
	rm -f $(OBJECTS)
